<?php 
	
	/**
	 * 获取用户中心默认页面所需的数据
	 * Enter description here ...
	 * @param $user_id
	 */

	function get_user_default($user_id)
	{
		$user_bonus = get_user_bonus(); 			//获取用户积分
		
		$sql = "SELECT pay_points,user_money,credit_line,last_login,is_validated FROM ".
				$GLOBALS['ecs']->table('users').
				" WHERE user_id = '$user_id'";
		$row = $GLOBALS['db']->getRow($sql);
		$info = array();
		
		$info['username'] = stripslashes($_SESSION['user_name']);
		$info['shop_name'] = $GLOBALS['_CFG']['shop_name'];
		$info['integeral'] = $row['pay_points'] . $GLOBALS['_CFG']['integral_name'];
		
		$last_time = !isset($_SESSION['last_time']) 		//session中没有的话就从数据库中读取上次登录时间
					 ? $row['last_login'] 
					 : $_SESSION['last_time'];
		if ($last_time == 0)
		{
			$_SESSION['last_time'] = $last_time = gmtime();
		}
		
		$info['last_time'] = local_date($GLOBALS['_CFG']['time_format'],$last_time);
		$info['surplus'] = price_format($row['user_money'],false);
		$info['bonus'] = sprintf($GLOBALS['_LANG']['user_bonus_info'],$user_bonus['bonus_count'],price_format($user_bonus['bonus_value'],false));
		
		$sql = "SELECT COUNT(*) FROM ".$GLOBALS['ecs']->table('order_info')." WHERE user_id = '" . $user_id ."' AND add_time > '" .local_strtotime('-1 months'). "'";
		$info['order_count'] = $GLOBALS['db']->getOne($sql);
		
//		include_once ROOT_PATH . 'includes/lib_order.php';
//		$sql = "SELECT order_id,order_sn "." FROM ".$GLOBALS['ecs']->table('order_info')." WHERE user_id = '" .$user_id ."' AND shipping_time > '".$last_time."'".order_query_sql('shipped');
//		$info['shipped_order'] = $GLOBALS['db']->getAll($sql);
		
		return $info;
						
	}

?>